#include "ParticleContent.h"

#include "ParticleContext.h"
#include "DescriptorParticle.h"

//#//include "StreamBinary.h"
#include "FileAccess.h"

using namespace ParticleEngine; 

const DescriptorParticle ParticleContent::Descriptor
(
	"Content", 
	[](ParticleContext& NewEng) { return new ParticleContent(NewEng); }
); 

ParticleContent::ParticleContent(ParticleContext& NewEng) :
	ParticleBase(NewEng, &ParticleContent::Descriptor),
	Heat(1.f)
{
}
ParticleContent::~ParticleContent(void)
{
}

void ParticleContent::Sole(void)
{
	this->Heat.Sole();
}
void ParticleContent::InteractionIndividual(ParticleBase*const Other, Vec<2, float>& Space, const float& DistanceSquared)
{
	this->InteractionKinetics(Other, Space, DistanceSquared);

	this->Heat.Interaction(Other->HasHeat());
}
ColorRGBA<unsigned char> ParticleContent::GetColor()
{
	const unsigned char f = (int)(this->HasHeat()->Volume * 255);
	return ColorRGBA<unsigned char> (f, 0, 255-f, 255);
}

void ParticleContent::SaveIndividual(std::ofstream& Strm)
{
	Heat.Save(Strm);
}
void ParticleContent::LoadIndividual(std::ifstream& Strm)
{
	Heat.Load(Strm);
}